<template>
  <div class="wrapp">
    <div class="wrapper" v-for="(item1, index1) in list" :key="index1">
      <div @click="click(index1)">{{ item1.title }}</div>
      <Coll class="coll">
        <div v-if="item1.unfold" style="max-height:500px;overflow-y: auto;">
          <div class="wee">
            <div class="wq"><div class="ww"></div></div>
          </div>
          <div v-for="(item2, index2) in item1.children" :key="index2">
            <div>{{ item2.subTitle }}</div>
            <div>{{ item2.content }}</div>
          </div>
        </div>
      </Coll>
    </div>
    <view class="view"> </view>
  </div>
</template>

<script>
import Coll from "@/utils/collapse-transition";
export default {
  components: {
    Coll
  },
  methods: {
    click(i) {
      this.list.map((item, index) => {
        if (index == i) {
          item.unfold = !item.unfold;
        } else {
          item.unfold = false;
        }
      });
    }
  },
  data() {
    return {
      list: [
        {
          title: "这是标题1",
          unfold: true,
          children: [
            {
              subTitle: "标题1",
              content: "这是内容这是内容这是内容1"
            },
            {
              subTitle: "标题2",
              content: "这是内容这是内容这是内容2"
            },
            {
              subTitle: "标题3",
              content: "这是内容这是内容这是内容3"
            }
          ]
        },
        {
          title: "这是标题2",
          unfold: false,
          children: [
            {
              subTitle: "标题1",
              content:
                "这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容1"
            },
            {
              subTitle: "标题2",
              content:
                "这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容2"
            },
            {
              subTitle: "标题3",
              content:
                "这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容这是内容3"
            }
          ]
        }
      ]
    };
  }
};
</script>

<style lang="less" scoped>
.wrapp {
  margin: auto;
  width: 100px;
  color: #333;
  .wrapper {
    border: 1px solid #333;
  }
  .view {
  }
}
</style>
